import request from "@/utils/request";
import type { getDacSourceForm, dacSourceTypeResponse, dacProResponse, 
    dacPointForm, dacPointResponse, dacBusinessBatchForm, DacBusinessBatchRespinse } from '@/api/dataControl/type.ts';
//统一管理接口
enum API {
    DacPro_URL = "/itp/data/perm/config",
    DacDetail_URL = "/itp/data/perm/business",
    DacSource_URL = "/itp/data/perm/source",
    DacPoint_URL = "/itp/data/perm/point",
    DacBusiness_URL = "/itp/data/perm/business",
    DacSearch_URL = "/itp/data/perm/search"
}
//暴露请求函数
//登录接口方法
export const getDacPro = (key: string) => request.get(`${API.DacPro_URL}/find/list?businessKey=${key}`);
export const saveDacPro = (data: dacProResponse) => request.post(`${API.DacPro_URL}/save/`, data);
export const delDacPro = (id: number | null) => request.get(`${API.DacPro_URL}/delete?id=${id}`);
export const getDacDetail = (id: number | null) => request.get(`${API.DacDetail_URL}/find/list?dataPermConfigId=${id}`);

export const getDacSource = (data: getDacSourceForm, page: number, size: number) => request.post(`${API.DacSource_URL}/page?current=${page}&size=${size}`, data);
export const saveDacSource = (data: dacSourceTypeResponse) => request.post(`${API.DacSource_URL}/save`, data);
export const delDacSource = (id: number | null) => request.get(`${API.DacSource_URL}/delete?id=${id}`);

export const getDacPoint = (data: dacPointForm, page: number, size: number) => request.post(`${API.DacPoint_URL}/page?current=${page}&size=${size}`, data);
export const saveDacPoint = (data: dacPointResponse) => request.post(`${API.DacPoint_URL}/save`, data);
export const delDacPoint = (id: number | null) => request.get(`${API.DacPoint_URL}/delete?id=${id}`);

export const getDacBusiness = (data: dacBusinessBatchForm) => request.post(`${API.DacBusiness_URL}/batch/info`, data);
export const saveDacBusiness = (data: DacBusinessBatchRespinse) => request.post(`${API.DacBusiness_URL}/batch/save`, data);

export default {
    getUserAuthAll: (current: number, size: number, data: any) => request.post(`${API.DacPoint_URL}/page?current=${current}&size=${size}`, data),
    bindPointBusiness: (data: any) => request.post(`${API.DacPoint_URL}/bind/business`, data),
    unbindPointBusiness: (data: any) => request.post(`${API.DacPoint_URL}/unbind/business`, data),
    searchCommon: (data: any) => request.post(`${API.DacSearch_URL}/common/data`, data), //高级搜索-通用下拉接口
    savePointAssign: (data: any) => request.post(`${API.DacPoint_URL}/assign/value`, data), //权限点授权
    getDataPermConfig: (current: number, size: number, param: any) => request.post(`${API.DacPro_URL}/page?current=${current}&size=${size}`, param), //数据权限选择
}
